<template>
  <div id="apptitle">
    <img @click="showindex()" id="apptitlelogo" alt="Vue logo" src="./assets/logo.png">
    <div id="apptitlename">
      {{ titleName }}
    </div>
  </div>
  <div id="showbody">
    <router-view></router-view>
  </div>
  <div id="food">
    <div>V1.1.0</div>
    <div class="fooddiv">{{username}}</div>
    <div class="fooddiv" @click="show(item)">切换用户</div>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
import {ref, reactive } from "vue"
export default {
  name: 'App',
  components: {
    HelloWorld
  },
  setup(){
    let titleName = ref('喷水龙王集团导航页')
    let username = ref('')
    return{
      titleName,
      username
    }
  },
  mounted(){
    this.init()
  },
  methods: {
    show() {
            this.$router.push('/user')
        },
    showindex() {
        this.$router.push('/index')
    },
    async init(){
      pxmu.loading({
          msg: '正在查询用户信息', //loading信息 为空时不显示文本
          close: false, // 自动关闭 为false时可在业务完成后调用 pxmu.closeload();手动关闭
          inscroll: true, //模态 不可点击和滚动
      })
      let res = await this.axios.post("/getuser",{})
      //手动关闭
      pxmu.closeload(100);//延时100毫秒关闭 默认0
      console.log(res)
      if (res.data.code !== 200) {
          pxmu.toast(res.data.msg)
      }else{
        this.username = res.data.name
        this.userobj.name = res.data.name
        this.userobj.id = res.data.id
        this.userobj.email = res.data.email
      }
    }
  }
}
</script>

<style>
/* #app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
} */
#apptitle {
  background-color: #e7e7e7;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  height: 6em;
}

#apptitlename {
  margin-top: auto;
  margin-bottom: auto;
  font-size: 2em;
}

#apptitlelogo {
  margin-top: auto;
  margin-bottom: auto;
  height: 5em;
  margin-left: 1em;
  margin-right: 1em;
  cursor: pointer;
}

html {
  height: 100%;
}

body {
  height: 100%;
  margin: 0;
}

#showbody {
  margin: 0.5em;
}

button {
  border-radius: 0.5em;
  /* 边框半径 */
  padding: 0.5em;
  border: none;
  /* 不显示轮廓线 */
  background: #1E90FF;
  /* 背景颜色 */
  cursor: pointer;
  /* 鼠标移入按钮范围时出现手势 */
  color: white;
  /* 字体颜色 */
}

button:hover {
  /* 鼠标移入按钮范围时 */
  background: #5599FF;
}

#app {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  min-height: 100%;
  min-width: 25em;
}

#food {
  margin-top: auto;
  background-color: #e7e7e7;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
}

.fooddiv {
  margin-left: auto;
}
.indexdiv {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
}
.indexdivtitle{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 2em;
    background-color: gainsboro;
    color: rgb(155, 97, 231);
}
.indextemplate{
    border: 5px solid gainsboro;
    margin-bottom: 1em;
}
</style>
